import React from 'react';
import { Form } from 'antd';
import moment from 'moment'
import { FormLayout } from '../../components';

const formatRangeTime = (t1, t2) => {
    if (!t1 && !t2) {
        return '--'
    }
    if (!t1) {
        return t2
    }
    if (!t2) {
        return t1
    }
    return `${moment(t1).format('YYYY-MM-DD HH:mm')} ~ ${moment(t2).format('HH:mm')}`;
}
export default function ArrangeDetail({ data, date }) {
    const { interviewLocation, interviewerEmployeeName, interviewWayName,
        interviewTypeName, interviewStartTime, interviewEndTime } = data || {};
    const typeCom = <Form.Item label="面谈类型">{interviewTypeName}</Form.Item>;
    const wayCom = <Form.Item label="面谈方式">{interviewWayName}</Form.Item>;
    const dateCom = <Form.Item label="面谈时间">{formatRangeTime(interviewStartTime, interviewEndTime)}</Form.Item>;
    const locationCom = <Form.Item label="面谈地点">{interviewLocation}</Form.Item>;
    const employeeCom = <Form.Item label="参与人">{interviewerEmployeeName}</Form.Item>;
    if (date) {
        return (
            <div>
                <FormLayout type="col2">
                    {typeCom}
                    {wayCom}
                </FormLayout>
                <FormLayout type="col2">
                    {dateCom}
                    {locationCom}
                </FormLayout>
                <FormLayout type="col2">
                    {employeeCom}
                </FormLayout>
            </div>
        );
    }
    return (
        <div>
            <FormLayout type="col2">
                {typeCom}
                {wayCom}
            </FormLayout>
            <FormLayout type="col2">
                {locationCom}
                {employeeCom}
            </FormLayout>
        </div>
    );
}
